#include "Game.h"
#include "TextureManager.h"
#include "SoundManager.h"
#include "ModelManager.h"
#include "WindowManager.h"
#include "KeyboardManager.h"
#include "MouseManager.h"
#include "JoystickManager.h"
#include "CameraManager.h"
#include "ActorManager.h"
#include "WmoGroup.h"

Game::Game()
{
	m_fElapsedTime = 0.0f;
	m_bIsExiting = false;
	m_pContentManager = ContentManager::GetInstance();
	m_pActorManager = ActorManager::GetInstance();
	m_pCameraManager = CameraManager::GetInstance();
	m_pGraphicsDeviceManager = GraphicsDeviceManager::GetInstance();
}

Game::~Game()
{
	delete m_pContentManager;
	delete m_pActorManager;
	delete m_pCameraManager;
}

void Game::Initialize()
{
	WindowManager::Initialize();
	m_pGraphicsDeviceManager->Initialize();
	m_pCameraManager->Initialize();
}

void Game::LoadContent()
{
	m_pContentManager->LoadContent();
}

void Game::Update(float elapsedTime)
{
	m_fElapsedTime = (float)glfwGetTime();

	KeyboardManager* keyboardManager = KeyboardManager::GetInstance();
	MouseManager* mouseManager = MouseManager::GetInstance();
	JoystickManager* joystickManager = JoystickManager::GetInstance();

	keyboardManager->Update();
	mouseManager->Update();
	joystickManager->Update();

	m_pCameraManager->Update(elapsedTime);
}

void Game::Draw()
{
	GuiManager::GetInstance()->Draw();

	glfwSwapBuffers();
}

void Game::UnloadContent()
{
}

void Game::Exit()
{
	m_bIsExiting = true;
}

const float Game::GetElapsedTime() const
{
	return m_fElapsedTime;
}

const bool Game::IsExiting() const
{
	return m_bIsExiting;
}

ContentManager* Game::GetContentManager() const
{
	return m_pContentManager;
}

ActorManager* Game::GetActorManager() const
{
	return m_pActorManager;
}

CameraManager* Game::GetCameraManager() const
{
	return m_pCameraManager;
}